package com.winglish.as3.exam.toeicspeaking 
{
	import com.winglish.as3.exam.toeicspeaking.impl.TSPart;
	import com.winglish.as3.utils.StringUtil;
	import com.winglish.as3.utils.NumberUtil;
	import com.winglish.as3.ui.WScrollBar;
	
	import flash.display.MovieClip;
	import flash.text.TextFieldAutoSize;
	import flash.events.MouseEvent;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author charmjin
	 */
	public class TSPart5 extends TSAnswer implements TSPart
	{
		public function TSPart5(mc:MovieClip, data:Object) 
		{
			super(mc, data, 5);
		}
		
		/**
		 * 사운드재생, 녹음, 공백시간 등이 끝나고 나서 실행하는 함수.
		 * @param	no
		 */
		public function action(no:int):void {
			var mcRoot:MovieClip = _root.mcRoot;
			trace(no);
			switch(no) {
				case 1 :	//preparing
					_root.gotoAndStop("part" + partNo + "_Q");
					mcRoot = _root.mcRoot;	//nextFrame 이동으로 mcRoot 내용이 달라지기 때문에 다시 넣기.
					break;
				case 2 :	//reading
					mcRoot.nextFrame();
					mcRoot.secTxt.text = NumberUtil.itostr(TSData["PART" + partNo][3]);
					break;
				case 4:
					mcRoot.nextFrame();
					mcRoot.secTxt.text = NumberUtil.itostr(TSData["PART" + partNo][5].split("r")[0]);
					break;
				case 6 :	//end
					_root.gotoAndStop("part" + partNo + "_A");
					answerSet();
					break;
			}
			
		}
		
		/**
		 * 피드백 텍스트 셋팅.
		 */
		override protected function answerSet():void {
			super.answerSet();
			
			var mc:MovieClip = _root.mcRoot.q0 as MovieClip;
			if (mc) {
				mc.queMc.content.txt.autoSize = TextFieldAutoSize.LEFT;
				mc.queMc.content.txt.text = StringUtil.strReplace(dataObj.quiz0.question,"|","\n");
				var _wsb0:WScrollBar = WScrollBar.GET( mc.queMc, { width: TSData.SCROLL_PART56_WIDTH, height: TSData.SCROLL_PART56_HEIGHT, offset: 5 } );
			}
		}
		
		/**
		 * 나의 답변, 모범 답변 사운드 셋팅.
		 * @param	ansArr
		 * @param	recArr
		 */
		override public function soundRecordSet(ansArr:Array, recArr:Array):void {
			super.soundRecordSet(ansArr, recArr);
		}
		
		/**
		 * 다시풀기 버튼 클릭
		 * @param	e
		 */
		override public function reStartBtnClick(e:MouseEvent):void {
			super.reStartBtnClick(e);
			dispatchEvent(new Event("reStart", true));
			_root.gotoAndPlay("part" + partNo);
		}

	}

}